package com.mcptt.config.body;

import com.cloudptt.api.product.func.call.CallAttr;
import com.cloudptt.api.product.log.Log;

import java.io.UnsupportedEncodingException;

public class XCapBodyCms {

	private int mcType = 0;
	private String xcapStr = "";
	private String mcIdStr = "";

	public XCapBodyCms(int mcType, String mcIdStr, String xcapStr)
	{
		Log.debug(this.getClass(),"mcType = " + mcType + "mcIdStr = " + mcIdStr);
		this.mcType = mcType;
		this.mcIdStr = mcIdStr;
		this.xcapStr = xcapStr;
	}

	public String toString()
	{
		StringBuffer strBuff = new StringBuffer();
		strBuff.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\r\n");
		strBuff.append("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">").append("\r\n");
		strBuff.append("<list>").append("\r\n");
		;
		if(mcIdStr != null
				&& mcIdStr.length() > 0)
		{
			if(CallAttr.McType_McPtt == mcType) {
				strBuff.append("<entry ").append("uri=\"").append("org.3gpp.mcptt.user-profile/users/").append(mcIdStr).append("\"/>").append("\r\n");
				strBuff.append("<entry ").append("uri=\"").append("org.3gpp.mcptt.ue-config/users/").append(mcIdStr).append("\"/>").append("\r\n");
			}
			else if(CallAttr.McType_McVideo == mcType) {
				strBuff.append("<entry ").append("uri=\"").append("org.3gpp.mcvideo.user-profile/users/").append(mcIdStr).append("\"/>").append("\r\n");
				strBuff.append("<entry ").append("uri=\"").append("org.3gpp.mcvideo.ue-config/users/").append(mcIdStr).append("\"/>").append("\r\n");
			}
			else if(CallAttr.McType_McData == mcType) {
				strBuff.append("<entry ").append("uri=\"").append("org.3gpp.mcdata.user-profile/users/").append(mcIdStr).append("\"/>").append("\r\n");
				strBuff.append("<entry ").append("uri=\"").append("org.3gpp.mcdata.ue-config/users/").append(mcIdStr).append("\"/>").append("\r\n");
			}
		}

		strBuff.append("</list>").append("\r\n");
		strBuff.append("</resource-lists>");

		try {
			return new String(strBuff.toString().getBytes(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return strBuff.toString();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
